<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="编码规则" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<script language="javascript">
	function changeEnabled(){
		if(document.getElementsByName("enabledRadio")[0].checked){
			document.getElementById("enabled").value="Y";
		}else{
			document.getElementById("enabled").value="N";
		}
	}
	function doSave(){
		document.getElementById("buttonDiv").style.display="none";
		document.getElementById("waitDiv").style.display="";
		frm.submit();
	}
	function doChangeGenerateRule(obj){
		if(obj.value=='MANUAL'){
			document.getElementById("prefix").disabled="true";
			document.getElementById("separator").disabled="true";
			document.getElementById("numberLength").disabled="true";
			document.getElementById("prefix").className="TextBox readonly";
			document.getElementById("separator").className="TextBox readonly";
			document.getElementById("numberLength").className="TextBox readonly";
		}else{
			document.getElementById("prefix").disabled="";
			document.getElementById("separator").disabled="";
			document.getElementById("numberLength").disabled="";
			document.getElementById("prefix").className="TextBox";
			document.getElementById("separator").className="TextBox";
			document.getElementById("numberLength").className="TextBox";
			if(obj.value=='AUTO_TYPE_CODE'){
				document.getElementById("prefixTr").style.display="none";
			}else{
				document.getElementById("prefixTr").style.display="";
			}
		}
	}
	function doInit(){
		showFormErrorMsg();
	}
</script>
</head>
<body oncontextmenu="return false" scroll="no" style="background: #EAFAFF;">
<div class="sheet-main" id="bodyDiv" style="height:400px;">
		<form name="frm" method="post">
  		<div class="sheet-list">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table-0">
					<tr>
						<td valign="top">
							<br>
							<%@ include file="../inc/PageTop.jsp"%>
							<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center" class="table-a">
								<tr>
							      	<th >名称：</th>
							      	<td>
							      		${command.title}
							     	</td>
								</tr>
								<tr>
							      	<th>方式：</th>
							      	<spring:bind path="command.generateRule">
							      	<td>
							      		<select id="${status.expression}" name="${status.expression}" onChange="doChangeGenerateRule(this);">
											<option value="MANUAL" <c:if test="${status.value=='MANUAL'}">selected</c:if>>手工录入</option>
											<c:if test="${command.dataType==1 || command.dataType==2}">
												<option value="AUTO_PREFIX" <c:if test="${status.value=='AUTO_PREFIX'}">selected</c:if>>使用前缀自动产生</option>
											</c:if>
											<c:if test="${command.dataType==2}">
												<option value="AUTO_TYPE_CODE" <c:if test="${status.value=='AUTO_TYPE_CODE'}">selected</c:if>>使用类别代码自动产生</option>
											</c:if>
											<c:if test="${command.dataType==3}">
												<option value="AUTO_YEAR" <c:if test="${status.value=='AUTO_YEAR'}">selected</c:if>>按年自动产生</option>
												<option value="AUTO_MONTH" <c:if test="${status.value=='AUTO_MONTH'}">selected</c:if>>按月自动产生</option>
												<option value="AUTO_DATE" <c:if test="${status.value=='AUTO_DATE'}">selected</c:if>>按日自动产生</option>
											</c:if>
										</select>
							     	</td>
							     	</spring:bind>
								</tr>
								<tr id="prefixTr" <c:if test="${command.generateRule=='AUTO_TYPE_CODE'}">style="display:none"</c:if>>
							      	<th>前缀：</th>
							      	<spring:bind path="command.prefix">
							      	<td>
							      		<input type="text" maxlength="10" onKeyUp="goNextInput('separator');" id="${status.expression}" name="${status.expression}" value="${status.value}" <c:if test="${command.generateRule!='MANUAL'}">class="TextBox"</c:if><c:if test="${command.generateRule=='MANUAL'}">class="TextBox readonly" disabled</c:if>>
								          <script language="javascript">
								          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',1,'prefix');
								          </script>
							     	</td>
							     	</spring:bind>
								</tr>
								<c:if test="${command.dataType==3}">
								<tr>
							      	<th>帐套规则：</th>
							      	<spring:bind path="command.tallySetRule">
							      	<td>
							      		<select id="${status.expression}" name="${status.expression}">
											<option value="UNIFY" <c:if test="${status.value=='UNIFY'}">selected</c:if>>所有帐套统一编码</option>
											<option value="INDEPENDENCE" <c:if test="${status.value=='INDEPENDENCE'}">selected</c:if>>不同帐套独立编码（系统自动增加前缀扩展）</option>
										</select>
							     	</td>
							     	</spring:bind>
								</tr>
								</c:if>
								<tr>
							      	<th>分隔符：</th>
							      	<spring:bind path="command.separator">
							      	<td>
							      		<input type="text" maxlength="1" onKeyUp="goNextInput('numberLength');" id="${status.expression}" name="${status.expression}" value="${status.value}" <c:if test="${command.generateRule!='MANUAL'}">class="TextBox"</c:if><c:if test="${command.generateRule=='MANUAL'}">class="TextBox readonly" disabled</c:if>>
								          <script language="javascript">
								          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',2,'separator');
								          </script>
							     	</td>
							     	</spring:bind>
								</tr>
								<tr>
							      	<th>流水号长度：</th>
							      	<spring:bind path="command.numberLength">
							      	<td>
							      		<input type="text" maxlength="1" onKeyUp="goNextInput('printFoot');" id="${status.expression}" name="${status.expression}" value="${status.value}" <c:if test="${command.generateRule!='MANUAL'}">class="TextBox"</c:if><c:if test="${command.generateRule=='MANUAL'}">class="TextBox readonly" disabled</c:if>>
										<c:if test="${status.errorCode=='typeMismatch'}">
								          <script language="javascript">
								          	setFormErrorMsg('流水号长度只能输入整数',3,'numberLength');
								          </script>
								      	</c:if>
							     	</td>
							     	</spring:bind>
								</tr>
								<c:if test="${command.dataType==3}">
								<tr>
							      	<th>打印页脚：</th>
							      	<spring:bind path="command.printFoot">
							      	<td>
										<textarea class="TextBox" style="width:300px;height:80px" id="${status.expression}" name="${status.expression}" title="将出现在打印单据的页脚上。">${status.value}</textarea>
								          <script language="javascript">
								          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',4,'printFoot');
								          </script>
							     	</td>
							     	</spring:bind>
								</tr>
								</c:if>
							</table>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-buttom" id="buttonDiv">
				<input type="button" class="buttom-a" value=" 保 存 " onClick="doSave();">
			</div>
			<div class="modal-buttom" id="waitDiv" style="display:none">
				<span>请稍候...</span>
			</div>
		</form>
</div>
</body>
</html>